package org.example.controller;


import lombok.extern.slf4j.Slf4j;
import org.example.common.JsonResult;
import org.example.service.utils.FileUploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private FileUploadUtils fileUploadUtils;

    @PostMapping("/upload")
    public JsonResult upload(MultipartFile file) {
        log.info("上传文件:{}",file);
        fileUploadUtils.upload(file,file.getOriginalFilename());
        return JsonResult.ok(true);
    }
}
